/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "grade_item")
@NamedQueries({
    @NamedQuery(name = "GradeItem.findAll", query = "SELECT g FROM GradeItem g"),
    @NamedQuery(name = "GradeItem.findByGiId", query = "SELECT g FROM GradeItem g WHERE g.giId = :giId"),
    @NamedQuery(name = "GradeItem.findByGiDescrip", query = "SELECT g FROM GradeItem g WHERE g.giDescrip = :giDescrip"),
    @NamedQuery(name = "GradeItem.findByGiName", query = "SELECT g FROM GradeItem g WHERE g.giName = :giName"),
    @NamedQuery(name = "GradeItem.findByGiScore", query = "SELECT g FROM GradeItem g WHERE g.giScore = :giScore")})
public class GradeItem implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "gi_id")
    private Integer giId;
    @Column(name = "gi_descrip")
    private String giDescrip;
    @Basic(optional = false)
    @Column(name = "gi_name")
    private String giName;
    @Basic(optional = false)
    @Column(name = "gi_score")
    private double giScore;
    @JoinColumn(name = "gis_id", referencedColumnName = "gis_id")
    @ManyToOne(fetch = FetchType.LAZY)
    private GradeItemStandard gradeItemStandard;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "gradeItem", fetch = FetchType.LAZY)
    private List<Grade> gradeList;

    public GradeItem() {
    }

    public GradeItem(Integer giId) {
        this.giId = giId;
    }

    public GradeItem(Integer giId, String giName, double giScore) {
        this.giId = giId;
        this.giName = giName;
        this.giScore = giScore;
    }

    public Integer getGiId() {
        return giId;
    }

    public void setGiId(Integer giId) {
        this.giId = giId;
    }

    public String getGiDescrip() {
        return giDescrip;
    }

    public void setGiDescrip(String giDescrip) {
        this.giDescrip = giDescrip;
    }

    public String getGiName() {
        return giName;
    }

    public void setGiName(String giName) {
        this.giName = giName;
    }

    public double getGiScore() {
        return giScore;
    }

    public void setGiScore(double giScore) {
        this.giScore = giScore;
    }

    public GradeItemStandard getGradeItemStandard() {
        return gradeItemStandard;
    }

    public void setGradeItemStandard(GradeItemStandard gradeItemStandard) {
        this.gradeItemStandard = gradeItemStandard;
    }

    public List<Grade> getGradeList() {
        return gradeList;
    }

    public void setGradeList(List<Grade> gradeList) {
        this.gradeList = gradeList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (giId != null ? giId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GradeItem)) {
            return false;
        }
        GradeItem other = (GradeItem) object;
        if ((this.giId == null && other.giId != null) || (this.giId != null && !this.giId.equals(other.giId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.GradeItem[giId=" + giId + "]";
    }

}
